<?php

class faq_catagory
{
	var $catagory;

	function faq_catagory($catagory)
	{
		$this->catagory = $catagory;
	}
	
	function render()
	{
		global $lang, $skin_dir;
		
		$title = '<a href="faq.php?id=' . $this->catagory['fc_id'] . '">' . $this->catagory['fc_name'] . '</a>';
		$subtitle = $this->catagory['fc_questioncount'] . ' ' . $lang['FAQQuestions'] . '. ' . 
					($this->catagory['fc_questioncount'] - $this->catagory['fc_answeredcount']) . ' ' . $lang['FAQUnanswered'] . '.';
		$description = $this->catagory['fc_description'];
		$admin = getAdminControls('faqcatagories', $this->catagory['fc_id']);
		
		include $skin_dir . 'tpl/faqCatagory.tpl';
	}
}

class faq_question
{
	var $question;
	var $order;
	var $catagory;

	function faq_question($question, $catagory, $order)
	{
                global $style;
                $style->addJavascript('js/ajax.js');
                $style->addJavascript('js/faq.js');

		$this->question = $question;
		$this->order = $order;
		$this->catagory = $catagory;
	}
	
	function render()
	{
		global $lang, $skin_dir;
				
		$question = $this->question['fq_question'];
		$answer = $this->question['fq_answer'];
		$answer_id = 'faq_answer_' . $this->question['fq_id'];
		$link_id = 'faq_link_' . $this->question['fq_id'];
		$about_question = '';
		
		if($this->question['fq_submitteddriver'] != '')
		{
			$about_question .= $lang['FAQSubmittedBy'] . ' <a href="drivers.php?id=' . $this->question['fq_submittedby'] . 
								'">' . $this->question['fq_submitteddriver'] . '</a>';
			if($this->question['fq_submitteddate'] != '')
			{
				$about_question .= ' ' . $lang['At'] . ' ' . $this->question['fq_submitteddate'] . '. ';
			}
			else
			{
				$about_question .= '.';
			}
		}
		
		if($this->question['fq_answereddriver'] != '')
		{
			$about_question .= $lang['FAQAnsweredBy'] . ' <a href="drivers.php?id=' . $this->question['fq_answeredby'] . 
								'">' . $this->question['fq_answereddriver'] . '</a>';
			if($this->question['fq_answereddate'] != '')
			{
				$about_question .= ' ' . $lang['At'] . ' ' . $this->question['fq_answereddate'] . '. ';
			}
			else
			{
				$about_question .= '.';
			}
		}
				
		$useful_url = '';
		$useful_id = 'faq_useful_' . $this->question['fq_id'];
		$faq_id = $this->question['fq_id'];
		
		if($this->question['fq_answer'] == '')
		{
			$useful_url = $lang['FAQNoAnswer'];
			$show_url = '';;
		}
		else if(isset($_SESSION['valid_id']))
		{
			$useful_url = '<a id="' . $useful_id . '" href="javascript:makeRequest(\'ajax/faq_useful.php\', \'?id=' . $faq_id . '\', \'' . 
							$useful_id . '\')">' . $this->question['fq_useful'] . ' ' . $lang['FAQUsefulAsk'] . '</a> | ';
			$show_url = '<a id="' . $link_id . '" href="javascript:toggleDisplay(\'' . $answer_id . '\', \'' . $link_id . '\', \'' . 
							$lang['Show'] . ' ' . $lang['FAQAnswer'] . '\', \'' . $lang['Hide'] . ' ' . $lang['FAQAnswer'] . '\')">' .
        					$lang['Show'] . ' ' . $lang['FAQAnswer'] . '</a>';
		}
		else
		{
			$useful_url = $this->question['fq_useful'] . ' ' . $lang['FAQUsefulInfo'] . ' | ';
			$show_url = '<a id="' . $link_id . '" href="javascript:toggleDisplay(\'' . $answer_id . '\', \'' . $link_id . '\', \'' . 
							$lang['Show'] . ' ' . $lang['FAQAnswer'] . '\', \'' . $lang['Hide'] . ' ' . $lang['FAQAnswer'] . '\')">' .
        					$lang['Show'] . ' ' . $lang['FAQAnswer'] . '</a>';
		}
		
		$admin = getAdminControls('faqs', $this->question['fq_id']);
		
		include $skin_dir . 'tpl/faqQuestion.tpl';
		
		if(isset($_SESSION['valid_id']) && $this->question['fq_answer'] == '')
		{
			$question = $this->question['fq_id'];
			$order = $this->order;
			$catagory = $this->catagory;
			
			include $skin_dir . 'tpl/faqAnswer.tpl';
		}
	}
}

class faq_askquestion
{
	var $catagory;
	var $order;

	function faq_askquestion($catagory, $order)
	{
		$this->catagory = $catagory;
		$this->order = $order;
	}
	
	function render()
	{
		global $lang, $skin_dir;
		
		$catagory = $this->catagory;
		$order = $this->order;
		
		include $skin_dir . 'tpl/faqAsk.tpl';
	}
}
?>